/**
 * 
 */
package com.dhcc.DRGsHosp.web.controller;

import org.openkoala.koala.commons.InvokeResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dhcc.DRGsHosp.facade.DictionaryDataFacade;
import com.dhcc.DRGsHosp.facade.InitializeFacade;

/**
 * @author chl
 *
 */
@Controller("drgsHospWebController10")
@RequestMapping(value = "/dictionaryData")
public class DictionaryDataController {
	@Autowired
	private DictionaryDataFacade dictionaryDataFacade ;
	@Autowired
	private InitializeFacade initializeFacade ;
	
	
	@ResponseBody
	@RequestMapping(value = "/getDictionaryDataById")
	public InvokeResult getDictionaryDataById(Integer id) {
		return dictionaryDataFacade.findDictionaryDataById(id) ;
		
	}
	/**
	 *  @desp  ：获取字典明细
	 *  @Author： lhj
	 *  @param dicCode
	 *  @return
	 *  @Date  :2018年2月6日下午9:29:22
	 */
	@ResponseBody
	@RequestMapping(value = "/getDictionaryDataByCode")
	public InvokeResult getDictionaryDataByCode(String dicCode) {
		return dictionaryDataFacade.findDictionaryDataByCode(dicCode) ;
		
	}
	/**
	 *  @desp  ：保存字典详情
	 *  @Author： lhj
	 *  @param param
	 *  @return
	 *  @Date  :2018年2月7日上午10:10:38
	 */
	@ResponseBody  		
	@RequestMapping(value = "/saveDictionaryData")
	public InvokeResult saveDictionayData(String param) {
		try{
			dictionaryDataFacade.saveDictionayData(param);
			//更新系统字典全局变量
			initializeFacade.initializeSysDictionary();
			return InvokeResult.success();
		}catch(Exception e){
			return InvokeResult.failure(e.getMessage());
		}
	}
	/**
	 *  @desp  ：删除保存时不再列表里的内容
	 *  @Author： lhj
	 *  @param param
	 *  @param dicCode
	 *  @return
	 *  @Date  :2018年2月7日上午10:06:53
	 */
	@ResponseBody
	@RequestMapping(value = "/delInvalidDictionaryDatas")
	public InvokeResult delInvalidDictionaryDatas(String param,String dicCode) {
		dictionaryDataFacade.delInvalidDictionaryDatas(param,dicCode);
		return InvokeResult.success();
	}
	
}
